<template>
    <view class="l-grid-item l-grid-item-class grid-item" mut-bind:tap="tapGridItem">
        <slot></slot>
    </view>
</template>

<script>
export default {
    unicomGroup: ['grid'],
    data() {
        return {
            index: 0
        };
    },
    relations: {
        '../grid/index': {
            type: 'parent'
        }
    },
    externalClasses: ['l-grid-item', 'l-grid-item-class'],
    props: {
        key: String,
        cell: {
            type: Object,
            default: () => ({})
        }
    },
    mounted() {
        // 处理小程序 attached 生命周期
        this.attached();
    },
    watch: {
        key: function () {
            const e = this.getRelationNodes('grid')[0];
            if (e) {
                e.setData({
                    gridItems: [],
                    childNum: 0
                });
                e.initGrids();
            }
        }
    },
    show() {},
    methods: {
        attached() {},

        tapGridItem() {
            this.$emit(
                'linitemtap',
                {
                    detail: {
                        ...this
                    }
                },
                {
                    bubbles: true,
                    composed: true
                }
            );
        }
    },
    created: function () {}
};
</script>
<style>
.grid-item {
    max-width: initial;
    max-height: initial;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
</style>
